home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Softice Tuts / si-ug-chapter11.rtf < prev    next >
Text File  |  2000-05-25  |  14KB  |  324 lines

  1. CHAPTER 11 - Advanced Features
  2.  
  3.      11.01 Using Soft-ICE with other Debuggers
  4.      11.01.01 Debuggers that Use DOS
  5.      11.01.02 ACTION Command with other Debuggers
  6.      11.01.03 Special Considerations
  7.      11.01.04 Using Soft-ICE with CODEVIEW
  8.      11.01.05 Debuggers that Use 80386 Break Point Registers
  9.      11.02 User-Qualified Break Points
  10.      11.02.01 Example of a User-Qualified Break Point
  11.      11.03 The Window in Graphics Mode
  12.      11.04 Expanded Memory Debugging Features
  13.      11.05 Extended Memory Debugging Features
  14.  
  15. 11.01 Using Soft-ICE with other Debuggers
  16.  
  17.      Soft-ICE was designed to work well with other debuggers. Each debugger
  18.      offers different features, and therefore can require special
  19.      treatment. This section will describe some ways to use several
  20.      debuggers effectively.
  21.  
  22. 11.01.01 Debuggers that Use DOS
  23.  
  24.      Many debuggers use DOS and ROM BIOS to perform their display and
  25.      keyboard I/O. Special consideration must be taken when using these
  26.      debuggers with Soft-ICE (e.g., DEBUG, SYMDEB, and CODEVIEW), because
  27.      DOS and ROM BIOS are not fully re-entrant. If a break point occurs
  28.      while code is executing in DOS or BIOS, a re-entrancy problem can
  29.      occur.
  30.  
  31.      Soft-ICE provides optional re-entrancy warning, which is activated
  32.      with the WARN command. When WARN mode is on, Soft-ICE checks for DOS
  33.      or ROM BIOS re-entrancy before generating the ACTION that wakes up the
  34.      host debugger. When a re-entrancy problem is detected, Soft-ICE
  35.      displays a warning message and offers you the choice of continuing to
  36.      execute the code or returning to Soft-ICE.
  37.  
  38.      Note that Soft-ICE itself does not use DOS or ROM BIOS calls in its
  39.      debugging commands. This means that you can use Soft-ICE any time,
  40.      without the worry of re-entrancy problems.
  41.  
  42.      For more information on the WARN command, see section 5.4.
  43.  
  44. 11.01.02 ACTION Command with other Debuggers
  45.  
  46.      Different debuggers use different methods of activation For a
  47.      description of these methods see section 13.1.
  48.  
  49.      If you want to return to your debugger after a break point reached,
  50.      you must change the ACTION (see section 5.4) to work with your
  51.      debugger.
  52.  
  53.      In most cases, the action that should be taken after a break point is
  54.      reached is INT3. For instance, DEBUG and SYMDEB will work best with
  55.      ACTION set to INT3.
  56.  
  57.      If INT3 doesn't work with your debugger, try INT1 or NMI. CODEVIEW
  58.      works best with ACTION set to NMI.
  59.  
  60. 11.01.03 Special Considerations
  61.  
  62.      When a break point is set, you must be careful not to set off the
  63.      break point unintentionally. For instance, if you set a memory break
  64.      point at 0:0, then use your debugger to dump memory location 0:0,
  65.      Soft-ICE will be triggered. If ACTION is set to go to your debugger,
  66.      then your debugger will be triggered by itself. Since some debuggers
  67.      cannot be re-entrant, this could be a fatal problem. This problem can
  68.      also occur with other debugging functions, such as editing or
  69.      unassembling.
  70.  
  71.      For this reason, it is a good practice to disable the Soft-ICE break
  72.      points once Soft-ICE has helped you get to the point where you want to
  73.      look around with your debugger.
  74.  
  75. 11.01.04 Using Soft-ICE with CODEVIEW
  76.  
  77.      Soft-ICE works best with CODEVIEW when CODEVIEW is either in Assembler
  78.      mode or Mixed mode. When CODEVIEW is in Source mode with higher-level
  79.      languages it does not always break correctly. It is always best to use
  80.      ACTION NMI when you want Soft-ICE to wake up CODEVIEW.
  81.  
  82. 11.01.05 Debuggers that Use 80386 Break Point Registers
  83.  
  84.      The 80386 has 4 break point registers that are available for use by
  85.      debuggers. Soft-ICE uses these for its memory byte, word and double
  86.      word break points. If the debugger you are using Soft-ICE with uses
  87.      these debug registers there will be a conflict. There are two ways to
  88.      handle this problem.
  89.  
  90.      1. Disable the use of 80386 break point registers in the debugger you
  91.      are using Soft-ICE with. Check the documentation of your other
  92.      debugger for a description of how to do this.
  93.  
  94.      2. Some debuggers automatically use the break point registers if they
  95.      detect an 80386 processor with no method of turning them off (some
  96.      versions of SYMDEB do this). For these debuggers do the following:
  97.  
  98.    * Bring up the Soft-ICE window before you start the other debugger.
  99.    * Turn on Soft-ICE's break mode with the BREAK command (you may want to
  100.      do this in the INIT statement of S-ICE.DAT if you are doing this
  101.      frequently).
  102.    * Start up your other debugger.
  103.    * You may now pop up the Soft-ICE window and turn the Soft-ICE break
  104.      mode off if desired.
  105.  
  106. 11.02 User-Qualified Break Points
  107.  
  108.      Occasionally you may have the need for a very specific set of break
  109.      point conditions. If the special conditions require qualifying
  110.      register values or memory values, you can write a break point
  111.      qualification routine.
  112.  
  113.      Soft-ICE contains a very general mechanism for calling user-written
  114.      break point qualification routines: the ACTION command. When you use
  115.      the ACTION command, Soft-ICE can route all break points through
  116.      special interrupt vector. However, before break points can be routed,
  117.      the qualification routine must be placed in memory, and the interrupt
  118.      vector must be pointing to the qualification routine.
  119.  
  120.      All registers are identical to the values when the Soft-ICE break
  121.      point occurred. It is the responsibility of the qualification routine
  122.      to save and restore the registers. If your qualification routine
  123.      detects a match of break point conditions, it can do a variety of
  124.      activities. Some examples of useful activities that a routine can do
  125.      when a match is found are:
  126.  
  127.    * store information for later
  128.    * send the information directly to a printer or serial terminal
  129.    * issue an INT 3 instruction to bring up Soft-ICE The command 13HERE
  130.      must be turned on in order for the INT 3 to bring up Soft-ICE (see
  131.      section 5.4).
  132.  
  133.      If conditions do not match, the qualification routine in should
  134.      execute an IRET instruction. To summarize:
  135.  
  136.      1. Create a break point qualification routine in your code space, or
  137.      anywhere in free memory. The routine must preserve registers. After
  138.      comparing the desired conditions, the routine can execute either an
  139.      INT 3 to bring up Soft-ICE, or an IRET to continue.
  140.  
  141.      2. Point an unused interrupt vector to your qualification routine.
  142.      This can be done either within your code or from Soft-ICE.
  143.  
  144.      3. In Soft-ICE, set ACTION to the interrupt- number that was used to
  145.      point to your qualification routine.
  146.  
  147.      4. In Soft-ICE, set 13HERE on. This is necessary to bring up Soft-ICE
  148.      after the conditions have been met.
  149.  
  150.      5. Set the Soft-ICE general break point conditions. When any of these
  151.      break point conditions are met, your qualification routine will be
  152.      called.
  153.  
  154. 11.02.01 Example of a User-Qualified Break Point
  155.  
  156.      This section contains an example of a user-qualified break point that
  157.      compares for the conditions of U = 3, BX = 4 and CX = 5 when a break
  158.      point goes off.
  159.  
  160.      First, we create the qualification routine. For the purposes of this
  161.      example, we will assemble the command directly into memory with the
  162.      Soft- ICE interactive assembler. For this example we will arbitrarily
  163.      assemble the routine at location 9000:0H. The following statements are
  164.      entered into Soft-ICE :
  165.  
  166.      A 9000:0
  167.       9000:0 CMP AX,3
  168.       9000:3 JNE 10
  169.       9000:5 CMP BX,4
  170.       9000:7 JNE 10
  171.       9000:A CMP CX,5
  172.       9000:D JNE 10
  173.       9000:F INT3
  174.       9000:10 IRET
  175.  
  176.      Now that the routine is in memory, you must point an interrupt vector
  177.      to the routine. For this example, we arbitrarily pick INT 99H. To
  178.      place 9000:0H in the INT 99H vector enter:
  179.  
  180.      ED 0:99*4 9000:0
  181.  
  182.      Set the ACTION command so that Soft-ICE will call your break point
  183.      qualification routine on every break point.
  184.  
  185.      ACTION 99
  186.  
  187.      Set I3HERE on so the qualification routine can activate Soft-ICE when
  188.      the conditions occur.
  189.  
  190.      I3HERE ON
  191.  
  192.      Now you need to set the break points. For this example, we are just
  193.      interested when the registers are: AX = 3, BX = 4, CX = 5 in a
  194.      specific program, and we do not want any further qualification. To do
  195.      this, use a range break point on memory read :
  196.  
  197.      BPR segment:starting-offset segment:ending-offset
  198.  
  199.      This will cause your break point qualification routine to be called
  200.      after every instruction is executed in the specified memory range.
  201.      When the register conditions do not match, then the IRET instruction
  202.      is executed. When the conditions finally match the specified
  203.      qualifications, the INT 3 is executed and Soft-ICE is popped up.
  204.  
  205.      When Soft-ICE pops up, the instruction pointer will be pointing at the
  206.      INT3 in your qualification routine (9OOO:FH in our example). To get to
  207.      the instruction after the one that caused the break point, you must
  208.      change the instruction pointer to point to the IRET instruction
  209.      (F000:10H in the example) and single step one time. This is
  210.      accomplished with the following Soft-ICE commands
  211.  
  212.      RIP IP + 1
  213.      T
  214.  
  215.      After your break conditions have gone off, remember to change the
  216.      ACTION command back to ACTION HERE that subsequent break points do not
  217.      go through your qualification routine.
  218.  
  219. 11.03 The Window in Graphics Mode
  220.  
  221.      The screen is switched to text mode when Soft-ICE is invoked. If the
  222.      screen was in graphics mode or 40-column mode, the graphics display is
  223.      not visible while the window is up. For users who must see the
  224.      graphics display while debugging, three features are provided. The
  225.      first feature allows the Soft-ICE window to display on a second
  226.      monitor (see the ALTSCR command, section 5.9). The second feature
  227.      allows you to restore the screen while you are doing P or T
  228.      instruction step commands (see the FLASH command, section 5.9). The
  229.      third feature allows you to restore the program screen temporarily
  230.      (see the RS command, section 5.9).
  231.  
  232.      If Soft-ICE does not seem to be following your program into graphics
  233.      mode, try turning WATCHV on (see section 5.9 for details).
  234.  
  235. 11.04 Expanded Memory Debugging Features
  236.  
  237.      A range break point or a break point on memory that is set in an EMM
  238.      mappable area will stay at that address no matter which EMM page is
  239.      mapped in.
  240.  
  241.      When debugging EMM programs, the EMMMAP command may also be very
  242.      useful. See section 5.6 for more information.
  243.  
  244.      The D, E, S, F, and C commands can be used to view or modify any
  245.      allocated EMM handle page. The page does not have to be currently
  246.      mapped in. The syntax of these commands is similar to that of the
  247.      commands when being used for non-EMM pages, except for the following :
  248.  
  249.    * In the D, E, S, and F commands, the address portion of the command
  250.      must be specified in the following way:
  251.  
  252.      Hhandle# Ppage# offset
  253.  
  254.      where handle is a number specifying which EMM handle to use, page is a
  255.      number specifying which EMM page to use, and offset is a number from 0
  256.      to 4000H, specifying the offset from the beginning of the page.
  257.      Example:
  258.  
  259.      DB H1 P3 0
  260.  
  261.      This command will dump bytes from page 3 of handle 1, starting at
  262.      offset 0.
  263.  
  264.    * The C command must be specified in the following way :
  265.  
  266.      C Hhandle# Ppage# offset1 L length offset2
  267.  
  268.      where handle and page are the same as above. offset1 is a number from
  269.      0 to 4000H, specifying the offset from the beginning of the page,
  270.      where the first data block to be compared is located. offset2 is a
  271.      number from 0 to 4000H, specifying the offset from the beginning of
  272.      the page, where the second data block to be compared is located.
  273.      Example :
  274.  
  275.      C H2 P4 00 L10 1000
  276.  
  277.      This command will compare the first 10 bytes of memory located at
  278.      offset 0 of page 4 of handle 2 with the first 10 bytes of memory
  279.      located at offset 1000 of page 4 of handle 2.
  280.  
  281.      Note : Subsequent uses of the D, E, S, F, and C commands will continue
  282.      to use the handle and page last specified. To get back to conventional
  283.      memory, use one of the above commands with a segment specified in the
  284.      address field, for example:
  285.  
  286.      D 0:0
  287.  
  288. 11.05 Extended Memory Debugging Features
  289.  
  290.      The D, E, S, F, and C commands can be used to view or modify extended
  291.      memory. Extended memory reserved by Soft-ICE can not be displayed. The
  292.      syntax of these commands is similar to that of the commands when being
  293.      used for conventional memory:
  294.  
  295.    * In the D, E, S, and F commands, the address portion of the command
  296.      must be specified in the following way: M megabyte address where
  297.      megabyte is a number specifying which megabyte to use, and address
  298.      specifies the address in the specified megabyte. Example:
  299.  
  300.      DB M 2 0:0
  301.  
  302.      This command will dump bytes from start of the megabyte starting at
  303.      linear address 200000H.
  304.  
  305.    * The C command must be specified in the following way :
  306.  
  307.      C M megabyte address1 L length address2
  308.  
  309.      where megabyte and address1 are the same as above. address2 specifies
  310.      the address in the specified megabyte, where the second data block to
  311.      be compared is located.Example:
  312.  
  313.      C M 3 1000:2000 L10 3000:4000
  314.  
  315.      This command will compare the first 10 bytes of memory located at
  316.      1000:2000 with the first 10 bytes of memory located at 3000:4000.
  317.  
  318.      Note : Subsequent uses of the D, E, S, F, and C commands will continue
  319.      to use the last megabyte specified. To get back to megabyte 0
  320.      (conventional memory), use one of the above commands with 0 specified
  321.      as the megabyte, for example:
  322.  
  323.      D M 0
  324.